﻿using System;
using System.Windows;
using System.Windows.Media;
using System.Diagnostics;

namespace LEDHelper
{
	static public class Tracer
	{
		public static void Error(string from, Exception ex)
		{
            //System.Windows.Forms.MessageBox.Show(ex.StackTrace,ex.Message);
			Send(MessageEventType.Error, ex.StackTrace, ex.Message);
			System.Media.SystemSounds.Beep.Play();
		}
        public static void Speak(string word2speak)
        {
            //EventDispatcher.Instance.voice.Speak(word2speak, SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync);
            //Item(0)单词男声Sam
            //Item(1)单词男声Mike
            //Item(2)单词女声Mary
            //Item(3)中文发音，如果是英文，就依单词字母一个一个发音
        }
		public static void Error(string from, string message)
		{
			Send(MessageEventType.Error, from, message);
			System.Media.SystemSounds.Beep.Play();
		}

		public static void Error(string from, string format, params object[] args)
		{
			Error(from, string.Format(format, args));
		}

		public static void Info(string from, string message)
		{
			Send(MessageEventType.Info, from, message);
		}

		public static void Info(string from, string format, params object[] args)
		{
			Info(from, string.Format(format, args));
		}

		public static void Verbose(string from, string message)
		{
			Send(MessageEventType.Verbose, from, message);
		}

		public static void Verbose(string from, string format, params object[] args)
		{
			Verbose( from, string.Format(format, args));
		}

		private static void Send(MessageEventType typ, string from, string message)
		{
                       
			MessageInfo info = new MessageInfo(typ, from, message); 
			//trace is allways used for all levels and can be de-activated in config
			Trace.TraceInformation(info.ToString()); 
			
		}
	}
}